class Board {
public:
    // 适用于N*N的矩阵
    bool checkWon(vector<vector<int> > board) {
        int row = board.size();
        int i, j, sum;
        //1. 行全为1， 即行的和为3
        for(i = 0; i < row; ++i){
            sum = 0;
            for(j = 0; j < row; ++j)
                sum += board[i][j];
            if(sum == row) return true;
        }
        //2. 列全为1， 列的和为3
        for(i = 0; i < row; ++i){
            sum = 0;
            for(j = 0; j < row; ++j)
                sum += board[j][i];
            if(sum == row) return true;
        }
        //3. 主对角全为1， 对角和为3
        sum = 0;
        for(i = 0; i < row; ++i){
            sum += board[i][i];
        }
        if(sum == row) return true;
        //4. 副对角全为1， 对角和为3
        sum = 0;
        for(i = 0; i < row; ++i){
            sum += board[row-i-1][i];
        }
        if(sum == row) return true;
        
        return false;
    }
};